import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AddressInfoVO, AddressInfoForm, AddressInfoQuery } from '@/api/system/addressInfo/types';

/**
 * 查询地址管理列表
 * @param query
 * @returns {*}
 */

export const listAddressInfo = (query?: AddressInfoQuery): AxiosPromise<AddressInfoVO[]> => {
  return request({
    url: '/electroniccommerce/addressInfo/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询地址管理详细
 * @param id
 */
export const getAddressInfo = (id: string | number): AxiosPromise<AddressInfoVO> => {
  return request({
    url: '/electroniccommerce/addressInfo/' + id,
    method: 'get'
  });
};

/**
 * 新增地址管理
 * @param data
 */
export const addAddressInfo = (data: AddressInfoForm) => {
  return request({
    url: '/electroniccommerce/addressInfo',
    method: 'post',
    data: data
  });
};

/**
 * 修改地址管理
 * @param data
 */
export const updateAddressInfo = (data: AddressInfoForm) => {
  return request({
    url: '/electroniccommerce/addressInfo',
    method: 'put',
    data: data
  });
};

/**
 * 删除地址管理
 * @param id
 */
export const delAddressInfo = (id: string | number | Array<string | number>) => {
  return request({
    url: '/electroniccommerce/addressInfo/' + id,
    method: 'delete'
  });
};
